/************************************************************************************************/
/*Lab 3: AssemblerClasses.hh									*/
/*												*/
/*Description: This header file declares the "AssemblerData", the "AssemblyCommands", and	*/
/*	       the "Comments" classes and commands for those classes that will be used for an 	*/
/*	       assembler.									*/
/*												*/
/*Modification Log:										*/
/*												*/
/*		2012/07/07 - Adjusted the "General" class and the "AssemblyCommands" class to	*/
/*			     not need destructors and made them store just a plain vector or	*/
/*			     string instead of a pointer to one.  Also created special return	*/
/*			     funtions to make accessing much easier then it was before. The	*/
/*			     section with these commands is called "Special Return Commands" and*/
/*			     will make it easier to access information deep in the classes.	*/
/*			     (Samuel Thacker)							*/
/*		2012/02/28 - Rewrote some of the classes and made it so "Directives" takes a	*/
/*			     vector of strings instead of a string. (Samuel Thacker)		*/
/*		2012/02/17 - Combined the "Comments", "Directives", and "Labels" classes into	*/
/*			     one general class, called "General". Changed the "AssemblerData"	*/
/*			     class to contain a vector of strings instead of 4 specific strings,*/
/*			     and adapted to the funtions related to it.  Changed how "errors"	*/
/*			     are stored from a vector of "Errors" classes, to a vector of	*/
/*			     strings. (Samuel Thacker)						*/
/*		2012/02/15 - Separated the "AssemblerData" class into a operation code,		*/
/*			     directives, and labels. (Samuel Thacker				*/
/*		2012/02/14 - Made this file a little more consistant in the way it is formatted.*/
/*			     Modified the return string functions to return strings instead of	*/
/*			     pointers.  Declared Length, Append commands, and one special	*/
/*			     command (tests if vector "error" is empty) for the "AssemblerData" */
/*			     class. --Note, may want to seperate directives and labels into	*/
/*			     their own separate vectors and classes.-- (Samuel Thacker)		*/
/*		2012/02/13 - Added "Errors" class and modified all vector and string variables	*/
/*			     to be pointers. (Samuel Thacker)					*/
/*		2012/02/10 - Did some slight modifications to the code to fix some potential	*/
/*			     bugs, renamed the file from "AssemblerData.h" to			*/
/*			     "AssemblerClasses.h", added comments to the end of each class	*/
/*			     declaration to help organize the file, and made some modifications	*/
/*			     to this comments section. (Samuel Thacker)				*/
/*		2012/02/09 - Creations of this header file with declarations of the 		*/
/*			     AssemberData, the AssemblyCommands, and the Comments classes,	*/
/*			     construtors and destructors for those classes, and some return	*/
/*			     commands for those structures. (Samuel Thacker)			*/
/*												*/
/*               ----Please report any modifications made to this file please----               */
/************************************************************************************************/

#ifndef ASSEMBLERCLASSES_HH
#define ASSEMBLERCLASSES_HH

#include <iostream>
#include <vector>
#include <string>

using namespace std;

class AssemblerData;
class AssemblyCommands;
class General;

class AssemblerData //Stores a list of assembly commands, a list of comments, and a list of data.
	{
	vector<AssemblyCommands> * data; //Where the assembly commands will be stored.
	vector<AssemblyCommands> * directives; //Where the directives are stored.
	vector<General> * labels; //Where the labels are stored.
	vector<General> * comments; //Where the comments will be stored.
	vector<unsigned int> * mc_data; //Where the machine code data will be stored.
	vector<string> * errors; //Where the errors that are encountered will be stored.

	public:
		/* Constructor and Destructor */
		AssemblerData();
		~AssemblerData();

		/* Return Commands */
		vector<AssemblyCommands> * ret_data(); //Returns "data" (pointer)
		vector<AssemblyCommands> * ret_dir(); //Returns "directives" (pointer)
		vector<General> * ret_lab(); //Returns "labels" (pointer)
		vector<General> * ret_com(); //Returns "comments" (pointer)
		vector<unsigned int> * ret_mcData(); //Returns "mc_data" (pointer)
		vector<string> * ret_err(); //Returns "errors" (pointer)

		/* Special Return Commands */

		// Data //
		vector<string> ret_data(unsigned int); //Returns the "code" vector stored at index position "i"
		string ret_data(unsigned int,unsigned int); //Returns the "code" stored at index position "j" of (*code)[i]
		unsigned int ret_dataLN(unsigned int); //Returns the line number stored at index position "i"
		string ret_dataFN(unsigned int); //Returns the file name stored at index position "i"

		// Directives //
		vector<string> ret_dir(unsigned int); //Returns the "code" vector stored at index position "i"
		string ret_dir(unsigned int,unsigned int); //Returns the "code" stored at index position "j" of (*directives)[i]
		unsigned int ret_dirLN(unsigned int); //Returns the line number stored at index position "i"
		string ret_dirFN(unsigned int); //Returns the file name stored at index position "i"

		// Labels //
		string ret_lab(unsigned int); //Returns the label stored at index position "i"
		unsigned int ret_labLN(unsigned int); //Returns the line number stored at index position "i"
		string ret_labFN(unsigned int); //Returns the file name stored at index position "i"

		// Comments //
		string ret_com(unsigned int); //Returns the label stored at index position "i"
		unsigned int ret_comLN(unsigned int); //Returns the line number stored at index position "i"
		string ret_comFN(unsigned int); //Returns the file name stored at index position "i"

		// MC Data //
		unsigned int ret_mcData(unsigned int); //Returns the code stored at index position "i"

		// Errors //
		string ret_err(unsigned int); //Returns the error stored at index position "i"

		/* Length Commands */
		unsigned int data_len(); //Returns the number of elements in "data"
		unsigned int dir_len(); //Returns the number of elements in "directives"
		unsigned int lab_len(); //Returns the number of elements in "labels"
		unsigned int com_len(); //Returns the number of elements in "comments"
		unsigned int mcData_len(); //Returns the number of elements in "mc_data"
		unsigned int err_len(); //Returns the number of elements in "errors"

		/* Append Commands */
		void data_append(vector<string>,unsigned int,string); //Multiple tokens to "Data"
		void dir_append(vector<string>,unsigned int,string); //Appends a directive to "directives"
		void lab_append(string,unsigned int,string); //Appends a label to "labels"
		void com_append(string,unsigned int,string); //Appends a comment to "comments"
		void mcData_append(unsigned int); //Appends machine code (integer) to "mc_data"
		void err_append(string); //Appends an error (string) tor "errors"

		/* Special Commands */
		bool err_empty(); //Checks if vector "error" is empty. 1 if it is and 0 if otherwise.
	}; //END class AssemblerData

class AssemblyCommands //Stores assembly commands or directives with the line number it was on and the name of the file.
	{
	/* Places where the assembly commands are stored. */
	vector<string> code; //A list of operation code or directives (can contain invalid instructions)
	unsigned int ln; //line number
	string fname; //file name

	public:
		/* Constructors */
		AssemblyCommands(vector<string>,unsigned int,string); //Constructor

		/* Return Commands */
		vector<string> ret_code(); //Returns "code"
		string ret_fname(); //returns what "fname" points to
		unsigned int ret_ln(); //returns "ln"
	}; //END class AssemblyCommands

class General //Stores a label or comment, and the line number it was on.
	{
	string gen; //Can store a directive, a label, or a comment.
	unsigned int ln; //Line number the string is on.
	string fname; //file name

	public:
		/* Constructor and Destructor */
		General(string,unsigned int,string); //Constructor

		/* Return Commands */
		string ret_gen(); //returns "gen"
		string ret_fname(); //returns "fname"
		unsigned int ret_ln(); //returns "ln"
	}; //END class Comments

#endif //ASSEMBLERCLASSES_HH
